/* Copyright 2015 David Overeem (dovereem@cox.net)
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * 
 * You may obtain a copy of the License at
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 */
package org.xtce.apps.editor.dialogs;

import java.awt.event.WindowEvent;
import org.xtce.toolkit.XTCEDatabase;
import org.xtce.toolkit.XTCESpaceSystemMetrics;

/**
 *
 * @author dovereem
 */
public class XTCEViewerDatabaseMetricsDialog extends javax.swing.JDialog {

    /** Creates new form XTCEViewerDatabaseMetricsDialog
     *
     * @param parent Java Frame of the parent window
     *
     * @param modal boolean indicating if this dialog should have modal
     * behavior
     *
     * @param xtcedb XTCEDatabase object to query for metrics
     *
     */

    public XTCEViewerDatabaseMetricsDialog( java.awt.Frame parent,
                                            boolean        modal,
                                            XTCEDatabase   xtcedb ) {

        super(parent, modal);
        initComponents();

        XTCESpaceSystemMetrics metrics = xtcedb.getMetrics();

        spaceSystemsTotal.setText( Long.toString( metrics.getNumberOfChildSpaceSystems() ) );
        tmParametersTotal.setText( Long.toString( metrics.getNumberOfTelemetryParameters() ) );
        tcParametersTotal.setText( Long.toString( metrics.getNumberOfTelecommandParameters() ) );
        parametersTotal.setText( Long.toString( metrics.getNumberOfParameters() ) );
        tmParameterTypesTotal.setText( Long.toString( metrics.getNumberOfTelemetryParameterTypes() ) );
        tcParameterTypesTotal.setText( Long.toString( metrics.getNumberOfTelecommandParameterTypes() ) );
        parameterTypesTotal.setText( Long.toString( metrics.getNumberOfParameterTypes() ) );
        argumentsTotal.setText( Long.toString( metrics.getNumberOfTelecommandArguments() ) );
        argumentTypesTotal.setText( Long.toString( metrics.getNumberOfTelecommandArgumentTypes() ) );
        telecommandsTotal.setText( Long.toString( metrics.getNumberOfTelecommands() ) );
        tmContainersTotal.setText( Long.toString( metrics.getNumberOfTelemetryContainers() ) );
        tcContainersTotal.setText( Long.toString( metrics.getNumberOfTelecommandContainers() ) );
        containersTotal.setText( Long.toString( metrics.getNumberOfContainers() ) );

        setLocationRelativeTo( parent );

    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        databaseMetricsPanel = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        spaceSystemsTotal = new javax.swing.JTextField();
        tmParametersTotal = new javax.swing.JTextField();
        tcParametersTotal = new javax.swing.JTextField();
        parametersTotal = new javax.swing.JTextField();
        tmParameterTypesTotal = new javax.swing.JTextField();
        tcParameterTypesTotal = new javax.swing.JTextField();
        parameterTypesTotal = new javax.swing.JTextField();
        argumentsTotal = new javax.swing.JTextField();
        argumentTypesTotal = new javax.swing.JTextField();
        telecommandsTotal = new javax.swing.JTextField();
        tmContainersTotal = new javax.swing.JTextField();
        tcContainersTotal = new javax.swing.JTextField();
        containersTotal = new javax.swing.JTextField();
        dismissButton = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("org/xtce/toolkit/MessagesBundle"); // NOI18N
        setTitle(bundle.getString("dialog_totals_text")); // NOI18N
        setResizable(false);

        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel1.setText(bundle.getString("dialog_metrics_databasetotals_label")); // NOI18N

        jLabel2.setText(bundle.getString("dialog_metrics_spacesystemcount_text")); // NOI18N

        jLabel3.setText(bundle.getString("dialog_metrics_tmparameters_text")); // NOI18N

        jLabel4.setText(bundle.getString("dialog_metrics_tcparameters_text")); // NOI18N

        jLabel5.setText(bundle.getString("dialog_metrics_totalparameters_text")); // NOI18N

        jLabel6.setText(bundle.getString("dialog_metrics_tmparametertypes_text")); // NOI18N

        jLabel7.setText(bundle.getString("dialog_metrics_tcparametertypes_text")); // NOI18N

        jLabel8.setText(bundle.getString("dialog_metrics_totalparametertypes_text")); // NOI18N

        jLabel9.setText(bundle.getString("dialog_metrics_tcarguments_text")); // NOI18N

        jLabel10.setText(bundle.getString("dialog_metrics_tcargumenttypes_text")); // NOI18N

        jLabel11.setText(bundle.getString("dialog_metrics_telecommands_text")); // NOI18N

        jLabel12.setText(bundle.getString("dialog_metrics_tmcontainers_text")); // NOI18N

        jLabel13.setText(bundle.getString("dialog_metrics_tccontainers_text")); // NOI18N

        jLabel14.setText(bundle.getString("dialog_metrics_totalcontainers_text")); // NOI18N

        spaceSystemsTotal.setEditable(false);

        tmParametersTotal.setEditable(false);

        tcParametersTotal.setEditable(false);

        parametersTotal.setEditable(false);

        tmParameterTypesTotal.setEditable(false);

        tcParameterTypesTotal.setEditable(false);

        parameterTypesTotal.setEditable(false);

        argumentsTotal.setEditable(false);

        argumentTypesTotal.setEditable(false);

        telecommandsTotal.setEditable(false);

        tmContainersTotal.setEditable(false);

        tcContainersTotal.setEditable(false);

        containersTotal.setEditable(false);

        dismissButton.setText(bundle.getString("general_dismiss_text")); // NOI18N
        dismissButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                dismissButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout databaseMetricsPanelLayout = new javax.swing.GroupLayout(databaseMetricsPanel);
        databaseMetricsPanel.setLayout(databaseMetricsPanelLayout);
        databaseMetricsPanelLayout.setHorizontalGroup(
            databaseMetricsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(databaseMetricsPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(databaseMetricsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, databaseMetricsPanelLayout.createSequentialGroup()
                        .addGroup(databaseMetricsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, 195, Short.MAX_VALUE)
                            .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(databaseMetricsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(tmParametersTotal, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(spaceSystemsTotal, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(databaseMetricsPanelLayout.createSequentialGroup()
                        .addGroup(databaseMetricsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel14)
                            .addComponent(jLabel13)
                            .addComponent(jLabel12)
                            .addComponent(jLabel11)
                            .addComponent(jLabel10)
                            .addComponent(jLabel9)
                            .addComponent(jLabel8)
                            .addComponent(jLabel7)
                            .addComponent(jLabel6)
                            .addComponent(jLabel5)
                            .addComponent(jLabel4))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 58, Short.MAX_VALUE)
                        .addGroup(databaseMetricsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(tcParametersTotal, javax.swing.GroupLayout.DEFAULT_SIZE, 65, Short.MAX_VALUE)
                            .addComponent(parametersTotal)
                            .addComponent(tmParameterTypesTotal)
                            .addComponent(tcParameterTypesTotal)
                            .addComponent(parameterTypesTotal)
                            .addComponent(argumentsTotal)
                            .addComponent(argumentTypesTotal)
                            .addComponent(telecommandsTotal)
                            .addComponent(tmContainersTotal)
                            .addComponent(tcContainersTotal)
                            .addComponent(containersTotal)))
                    .addComponent(dismissButton, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );

        databaseMetricsPanelLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {argumentTypesTotal, argumentsTotal, containersTotal, parameterTypesTotal, parametersTotal, spaceSystemsTotal, tcContainersTotal, tcParameterTypesTotal, tcParametersTotal, telecommandsTotal, tmContainersTotal, tmParameterTypesTotal, tmParametersTotal});

        databaseMetricsPanelLayout.setVerticalGroup(
            databaseMetricsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(databaseMetricsPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(databaseMetricsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(spaceSystemsTotal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(databaseMetricsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(tmParametersTotal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(databaseMetricsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(tcParametersTotal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(databaseMetricsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(parametersTotal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(databaseMetricsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(tmParameterTypesTotal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(databaseMetricsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(tcParameterTypesTotal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel7))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(databaseMetricsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(parameterTypesTotal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel8))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(databaseMetricsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(argumentsTotal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel9))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(databaseMetricsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(argumentTypesTotal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel10))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(databaseMetricsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(telecommandsTotal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel11))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(databaseMetricsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(tmContainersTotal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel12))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(databaseMetricsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(tcContainersTotal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel13))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(databaseMetricsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(containersTotal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel14))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(dismissButton)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(databaseMetricsPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(databaseMetricsPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void dismissButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_dismissButtonActionPerformed
        dispatchEvent( new WindowEvent(this, WindowEvent.WINDOW_CLOSING) );
    }//GEN-LAST:event_dismissButtonActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField argumentTypesTotal;
    private javax.swing.JTextField argumentsTotal;
    private javax.swing.JTextField containersTotal;
    private javax.swing.JPanel databaseMetricsPanel;
    private javax.swing.JButton dismissButton;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JTextField parameterTypesTotal;
    private javax.swing.JTextField parametersTotal;
    private javax.swing.JTextField spaceSystemsTotal;
    private javax.swing.JTextField tcContainersTotal;
    private javax.swing.JTextField tcParameterTypesTotal;
    private javax.swing.JTextField tcParametersTotal;
    private javax.swing.JTextField telecommandsTotal;
    private javax.swing.JTextField tmContainersTotal;
    private javax.swing.JTextField tmParameterTypesTotal;
    private javax.swing.JTextField tmParametersTotal;
    // End of variables declaration//GEN-END:variables

}
